﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="QuanLyChiNhanh.aspx.cs" Inherits="LogisticSystem.Admin.QuanLyChiNhanh" %>
<asp:Content ID="Content1" ContentPlaceHolderID="admin_content" runat="server">
<h2><a href="#">Quản Lý</a> &raquo; <a href="#" class="active">Chi Nhánh</a></h2>
<script type="text/javascript">

    //Lấy danh sách chi nhánh
    var SERVICE_URL_DSCN = "http://localhost:1237/LogisticsService.svc/dschinhanh";
    $(document).ready(function () {
        // Add the page method call as an onclick handler for the div.	       	            
        $.get(SERVICE_URL_DSCN, dscn);
    });
    function dscn(data) {
        for (var i = 0; i < data.length; i++) {            
            $("#dschinhanh").append("<tr><td>"+data[i].Ten+"</td><td class='action'><a href='#' class='view'>Xem Chi Tiết</a><a href='#' class='edit'>Cập Nhật</a><a class='delete' id='abc' href='#'>Xóa</a></td></tr>");
        }
    }

    //Lấy danh sách tinh thanh
    var SERVICE_URL_DSTT = "http://localhost:1237/LogisticsService.svc/dstinhthanh";
    $(document).ready(function () {
        // Add the page method call as an onclick handler for the div.	       	            
        $.get(SERVICE_URL_DSTT, dstt);
    });
    function dstt(data) {
        for (var i = 0; i < data.length; i++) {
            $("#dstinhthanh").append("<option value="+data[i].Ma+">"+data[i].Ten+"</option>");            
        }
    }

    //Thêm chi nhánh 
    $(document).ready(function () {
        $("#btn_themchinhanh").click(function () {
            var ten = $("#tenchinhanh").val();
            var diachi = $("#diachi").val();
            var sdt = $("#sdt").val();
            var matinhthanh = $("#dstinhthanh").val();
            var url = "http://localhost:1237/LogisticsService.svc/themchinhanh/" + ten + "/" + diachi + "/" + sdt + "/" + matinhthanh;
            $.get(url, function (data) { alert("Thêm thành công!"); location.reload(); });
        });
    });

    //Xóa Chi nhánh
    $(document).ready(function () { $("#abc").click(function () { alert("xóa!"); }); });

</script>

      <div id="main">
        <form action="" class="jNice">
          <h3>Danh Sách Chi Nhánh</h3>
          <table id="dschinhanh" cellpadding="0" cellspacing="0" class="table">
 
          </table>
          <h3>Thêm Chi Nhánh</h3>
          <fieldset>
            <p>
              <label>Tên Chi Nhánh:</label>
              <input type="text" class="text-long" id="tenchinhanh" />
            </p>
            <p>
              <label>Địa Chỉ:</label>
              <input type="text" class="text-long" style="width:500px" id="diachi" />
            </p>
            <p>
              <label>Tỉnh/Thành phố:</label>
              <select id="dstinhthanh">
                <option>---Tinh Thành---</option>
                                
              </select>
            </p>
            <p>
              <label>Số Điện Thoại:</label>
              <input type="text" class="text-medium" id = "sdt" />
            </p>
            <input type="button" value="Thêm Chi Nhánh" id="btn_themchinhanh"/>
          </fieldset>
        </form>
      </div>

      <a id='abc' href="#">abc</a>
</asp:Content>
